package com.xsomnus.java_basic.retry;

import lombok.extern.slf4j.Slf4j;

import java.time.LocalTime;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @author @xsomnus666_xiawenye★
 * @since 2019-08-12 23:01
 * 只有经历过地狱般的磨砺，才能练就创造天堂的力量； 只有流过血的手指，才能弹出世间的绝响
 */
@Slf4j
public class HelloService {

    private static AtomicLong helloTimes = new AtomicLong();


    public String hello() {
        long times = helloTimes.incrementAndGet();
        System.out.println("current thread: " + Thread.currentThread().getId());
        if (times % 4 != 0) {
            log.warn("发生异常，time：{}", LocalTime.now());
            throw new HelloRetryException("发生Hello异常");
        }
        return "hello";
    }
}
